Exemple #1
0
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
*/
$_SERVER['SCRIPT_NAME'] !== "/controller.php" ? require_once __DIR__ . "/classes/Requires.php" : (Links::$pretty = true);
require_once __DIR__ . "/markdown/markdown.php";
Functions::check_required_parameters(array($_GET['param1']));
$result = MySQLQueries::get_recipe_head_version($_GET['param1']);
$head = MySQLConnection::fetch_object($result);
if (isset($_GET['param2']) && !empty($_GET['param2'])) {
    $recipe_version = $_GET['param2'];
} else {
    $recipe_version = $head->recipe_version;
}
$result = MySQLQueries::get_recipe_by_version($_GET['param1'], $recipe_version);
$recipe = MySQLConnection::fetch_object($result);
$recipe = Functions::format_dates($recipe);
//Get recipe versions
$recipe_versions = array();
$result = MySQLQueries::get_recipe_versions($_GET['param1']);
while ($row = MySQLConnection::fetch_object($result)) {
    ////
    // Move head to the top of the array
    ////
    if ($row->id === $head->recipe_version) {
        array_unshift($recipe_versions, $row);
    } else {
        $recipe_versions[] = $row;
    }
}